/*
 * Copyright (c) 2023 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef NATIVE_NET_CONN_API_H
#define NATIVE_NET_CONN_API_H

/**
 * @addtogroup NetConn
 * @{
 *
 * @brief Provide C interface for the data network connection module of network management.
 *
 * @since 11
 * @version 1.0
 */

/**
 * @file native_net_conn_api.h
 *
 * @brief Provide C interface for the data network connection module of network management.
 *
 * @syscap SystemCapability.Communication.NetManager.Core
 * @since 11
 * @version 1.0
 */

#include "native_net_conn_type.h"
#include "netdb.h"

#ifdef __cplusplus
extern "C" {
#endif

/**
 * @brief 通过netId获取DNS结果.
 *
 * @param host 所需查询的host名.
 * @param serv 服务名.
 * @param hint 指向addrinfo结构体的指针.
 * @param res 存放DNS查询结果，以链表形式返回.
 * @param netId DNS查询netId 为0是使用默认netid查询.
 * @return 0 - 成功.
 * @return 201 - 缺少权限.
 * @return 401 - 参数错误.
 * @return 2100002 - 无法连接到服务.
 * @return 2100003 - 内部错误.
 * @permission ohos.permission.INTERNET
 * @syscap SystemCapability.Communication.NetManager.Core
 * @since 11
 * @version 1.0
*/
int32_t OH_NetConn_GetAddrInfo(char *host, char *serv, struct addrinfo *hint, struct addrinfo **res, int32_t netId);

/**
 * @brief 释放DNS结果.
 *
 * @param res DNS查询结果链表头.
 * @return 0 - 成功.
 * @return 201 - 缺少权限.
 * @return 401 - 参数错误.
 * @return 2100002 - 无法连接到服务.
 * @return 2100003 - 内部错误.
 * @permission ohos.permission.INTERNET
 * @syscap SystemCapability.Communication.NetManager.Core
 * @since 11
 * @version 1.0
*/
int32_t OH_NetConn_FreeDnsResult(struct addrinfo *res);

#ifdef __cplusplus
}
#endif

/** @} */
#endif /* NATIVE_NET_CONN_API_H */